package gridmath;

import preprocessing.WindowingSystem;
import datastructures.UserParameters;

public class FrequencyCalculator extends CaseMatrixBase {

	private final double[] freqMins;
	
	public FrequencyCalculator (UserParameters userparams, WindowingSystem windowmaker) {
		super(windowmaker, userparams.getMaxorder());
		
		double[][] windowBoundaries = windowmaker.getWindowBoundaries();
		freqMins = new double[windowBoundaries.length];
		for(int i=0; i<windowBoundaries.length; i++)
			freqMins[i] = windowBoundaries[i][0]; 
		
		specialTypeOfOperation = MatrixOperations.calculateFrequency;
		specialTypeOfOperand = null;	//expects null matrix
	}
	
	@Override
	public double doOperation (double operand) {
		switch(currentDimension) {
			case 1:
				return freqMins[i];
			case 2:
				return freqMins[i] * freqMins[j];
			case 3:
				return freqMins[i] * freqMins[j] * freqMins[k];
			default:
				return freqMins[i] * freqMins[j] * freqMins[k] * freqMins[m];
		}
	}

}
